<template>
  <div>
        <van-nav-bar title="我的跟帖" left-arrow @click-left="$router.back()">
        </van-nav-bar>
        <div class="item" v-for="item in commentList" :key="item.id">
            <div class="head">
                <img src="../assets/R-C (1).jpg"
                     alt />
                <div>
                    <p></p>
                    <span>{{item.create_date}}</span>
                </div>
                <span @click="replyFn(item.id)">回复</span>
            </div>
            <commentItem v-if="item.parent" :parent="item.parent" @replyEvent="replyFn"></commentItem>
        <div class="text">{{item.content}}</div>
        </div>
        <comment ref="footer" :obj="article" @refresh-page="getCommentList"></comment>
  </div>
</template>

<script>
import commentItem from "@/components/commentItem.vue"
import {userComments} from '@/api/user'
export default {
    data(){
        return{
            commentList:{}
        }
    },
    methods:{
        CommentListFn(){
            userComments().then(res=>{
                this.commentList=res.data.data
                console.log(res.data.data);
            })
        },
        replyFn(id){
            this.$refs.footer.handlerFocus()
            this.$refs.footer.parent_id=id
        },
        getCommentList(){
            post_comment(this.id).then(res=>{
                this.commentList=res.data.data
                this.article.comment_length=this.commentList.length
            })
        }
    },
    created(){
        this.CommentListFn()
    },
    components:{
        commentItem
    },
}
</script>

<style lang="less" scoped>
/deep/.van-nav-bar .van-icon {
    color: #333;
    font-size: 20px;
}
.van-nav-bar{
    border-bottom: 1px solid #fff;
    /deep/.van-icon-arrow-left{
        color: #000;
    }
}
.item {
    padding: 15px;
    border-bottom: 1px solid #ccc;
    .head {
        display: flex;
        justify-content: space-between;
        align-items: center;
        > img {
            width: (50/360) * 100vw;
            height: (50/360) * 100vw;
            display: block;
            border-radius: 50%;
        }
        > div {
            flex: 1;
            display: flex;
            flex-direction: column;
            margin-left: 10px;
            > span {
                font-size: 12px;
                color: #999;
                line-height: 25px;
            }
        }
        > span {
            color: #999;
            font-size: 13px;
        }
    }
    .text {
        font-size: 14px;
        color: #333;
        padding: 20px 0 10px 0;
    }
}
</style>